package com.kfm.coll;

import java.util.ArrayList;

public class Hero {

    private String name;
    private String element;
    private Integer level;
    private Integer order;
    private Integer star;

    public Hero(String name, String element, Integer level, Integer order, Integer star) {
        this.name = name;
        this.element = element;
        this.level = level;
        this.order = order;
        this.star = star;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getElement() {
        return element;
    }

    public void setElement(String element) {
        this.element = element;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public Integer getStar() {
        return star;
    }

    public void setStar(Integer star) {
        this.star = star;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", element='" + element + '\'' +
                ", level=" + level +
                ", order=" + order +
                ", star=" + star +
                '}';
    }

    // @Override
    public int compareTo(Object o) {
        // 假设按照等级排序
        Hero h = (Hero) o;
        return level - h.getLevel();
        // return 0;
    }
}

class HeroTest {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        Hero h1 = new Hero("魈", "风", 90, 1, 5);
        Hero h2 = new Hero("枫原万叶", "风", 90, 0, 5);
        Hero h3 = new Hero("胡桃", "火", 89, 1, 5);
        list.add(h1);
        list.add(h2);
        list.add(h3);

        System.out.println(list);
    }
}
